package com.tcenter.dao.entities;


import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 *
 */
@Entity
@Table(name = "task", catalog = "tcenterdb")
public class Task implements java.io.Serializable {

    private Integer id;
    private Subject subject;
    private String description;
    private Set<Student> studentTasks = new HashSet<Student>(0);


    public Task() {
    }

    public Task(Subject subject, String description) {
        this.subject = subject;
        this.description = description;
    }


    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "subject_id", nullable = false)
    public Subject getSubject() {
        return this.subject;
    }

    public void setSubject(Subject subject) {
        this.subject = subject;
    }

    @Column(name = "description", length = 256)
    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

//    @OneToMany(fetch = FetchType.LAZY, mappedBy = "studentTasks")
//    public Set<Student> getStudentTasks() {
//        return this.studentTasks;
//    }
//
//    public void setStudentTasks(Set<Student> studentTasks) {
//        this.studentTasks = studentTasks;
//    }

}
